package com.ruoyi.system.domain.vo;

import com.ruoyi.common.enums.TankEnums;
import com.ruoyi.common.enums.TankStatusEnums;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.TankInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel("设备Vo")
public class DeviceVo {
    @ApiModelProperty("线号")
    private Long lineNo;
    @ApiModelProperty("设备名称")
    private String name;
    @ApiModelProperty("生产单号")
    private String productionNumber;
    @ApiModelProperty("缸重")
    private int bottleWeight;
    @ApiModelProperty("分散频率")
    private int disperseFrequency;
    @ApiModelProperty("设备状态")
    private int status;
    @ApiModelProperty("当前所在步骤")
    private String step;
    @ApiModelProperty("控制班组")
    private List<String> controlTeamMembers;
    @ApiModelProperty("操作人")
    private String operator;
    @ApiModelProperty("背景图片")
    private String backgroundImage;
    @ApiModelProperty("红绿灯")
    private int redlamp;
    @ApiModelProperty("跳转图片")
    private String url;
    @ApiModelProperty("开始时间")
    private String startTime;
    @ApiModelProperty("产品名称")
    private String matlDes;
    public static DeviceVo  tankInfoToDeviceVo(TankInfo tankInfo){
        DeviceVo deviceVo = new DeviceVo();
        deviceVo.setLineNo(tankInfo.getLineNo());
        deviceVo.setName(tankInfo.getTank());
        deviceVo.setProductionNumber(tankInfo.getOrderNo());
        deviceVo.setBottleWeight(tankInfo.getTankWeight()==null?0:tankInfo.getTankWeight().intValue());
        deviceVo.setDisperseFrequency(tankInfo.getMixFrequency()==null?0:tankInfo.getMixFrequency().intValue());
        deviceVo.setStatus(tankInfo.getTankState()==null?0:tankInfo.getTankState().intValue());
        deviceVo.setStep(tankInfo.getOrderStatus()!=null?TankStatusEnums.getValueByKey(tankInfo.getOrderStatus().intValue()):null);
        //TODO:暂无中控班组人品字段
        List<String> controlTeamMembers=new ArrayList<>();
//        List<String> controlTeamMembers=new ArrayList<>();controlTeamMembers.add("张三");controlTeamMembers.add("李四");
//        deviceVo.setControlTeamMembers(controlTeamMembers);
        //TODO:暂无字段判断操作人
//        deviceVo.setOperator("王五");
        deviceVo.setBackgroundImage(chooseTankEunms(tankInfo.getTank())!=null?chooseTankEunms(tankInfo.getTank()).getImg():null);
        //TODO:暂无字段判断设配是否故障
        if(StringUtils.isNotBlank(tankInfo.getTank())){
            switch (tankInfo.getTank()){
                case "ADS":
                    deviceVo.setRedlamp(0);
//                    deviceVo.setOperator("王五");
//                    controlTeamMembers.add("张愁三");controlTeamMembers.add("李四与");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "TDS":
                    deviceVo.setRedlamp(1);
//                    deviceVo.setOperator("李户籍");
//                   controlTeamMembers.add("郑十八");controlTeamMembers.add("唐十九");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "T3":
                    deviceVo.setRedlamp(2);
//                    deviceVo.setOperator("王十一");
//                  controlTeamMembers.add("李艺术");controlTeamMembers.add("时间催");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "T4":
                    deviceVo.setRedlamp(0);
//                    deviceVo.setOperator("主操1");
//                    controlTeamMembers.add("张三");controlTeamMembers.add("李四");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "7K":
                    deviceVo.setRedlamp(1);
//                    deviceVo.setOperator("主操2");
//                    controlTeamMembers.add("张三");controlTeamMembers.add("李四");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "10K":
                    deviceVo.setRedlamp(2);
//                    deviceVo.setOperator("主操3");
//                    controlTeamMembers.add("李护");controlTeamMembers.add("王一岁");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;
                case "NPS乳液罐":
                    deviceVo.setRedlamp(0);
//                    deviceVo.setOperator("主操32");
//                    controlTeamMembers.add("隶属");controlTeamMembers.add("李四");
//                    deviceVo.setControlTeamMembers(controlTeamMembers);
                    break;

            }
        }else{
            deviceVo.setRedlamp(1);
        }
        deviceVo.setUrl(chooseTankEunms(tankInfo.getTank())!=null?chooseTankEunms(tankInfo.getTank()).getRouter():null);
        return deviceVo;


    }
    private static TankEnums chooseTankEunms(String tank) {
        if (tank == null) {
            return null;
        }
        TankEnums tankEnums =null;
        switch (tank) {
            case "ADS":
                tankEnums = TankEnums.ADS;
                break;
            case "TDS":
                tankEnums = TankEnums.TDS;
                break;
            case "T3":
                tankEnums = TankEnums.T3;
                break;
            case "T4":
                tankEnums = TankEnums.T4;
                break;
            case "7K":
                tankEnums = TankEnums.SEVENK;
                break;
            case "10K":
                tankEnums = TankEnums.TENK;
                break;
            case "NPS乳液罐":
                tankEnums = TankEnums.NPS_RYG;
                break;
        }
        return tankEnums;
    }
}
